Ext.define('Emp.ux.window.MessageBox', {
	
	requires: [
    	'Ext.window.MessageBox'
    ],
    
	singleton: true,
	
	formLoadFailure: function(form, action) {
		switch (action.failureType) {
			case Ext.form.action.Action.CLIENT_INVALID:
				Ext.Msg.show({
					title: '提示',
					msg: action.result.message,
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
				break;
			case Ext.form.action.Action.SERVER_INVALID:
				Ext.Msg.show({
					title: '提示',
					msg: action.result.message,
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
				break;
			case Ext.form.action.Action.CONNECT_FAILURE:
				Ext.Msg.show({
					title: '提示',
					msg: '连接超时或与服务器断开连接,请联系管理员!',
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
				break;
			case Ext.form.action.Action.LOAD_FAILURE:
				if(action.result.success) {
					Ext.Msg.show({
						title: '提示',
						msg: '数据不存在,请检查!',
						buttons: Ext.Msg.OK,
						icon: Ext.Msg.ERROR
					});
				} else {
					Ext.Msg.show({
						title: '提示',
						msg: action.result.message,
						buttons: Ext.Msg.OK,
						icon: Ext.Msg.ERROR
					});
				}
				break;
			default:
				Ext.Msg.show({
					title: '提示',
					msg: '服务器端错误',
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
		}
	},
	
	formSubmitFailure: function(form, action) {
		switch (action.failureType) {
			case Ext.form.action.Action.CLIENT_INVALID:
				Ext.Msg.show({
					title: '提示',
					msg: action.result.message,
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
				break;
			case Ext.form.action.Action.SERVER_INVALID:
				Ext.Msg.show({
					title: '提示',
					msg: action.result.message,
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
				break;
			case Ext.form.action.Action.CONNECT_FAILURE:
				Ext.Msg.show({
					title: '提示',
					msg: '连接超时或与服务器断开连接,请联系管理员!',
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
				break;
			case Ext.form.action.Action.LOAD_FAILURE:
				Ext.Msg.show({
					title: '提示',
					msg: action.result.message,
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
				break;
			default:
				Ext.Msg.show({
					title: '提示',
					msg: '服务器端错误',
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
		}
	},
	
	ajaxFailure: function(response, options) {
		switch (response.status) {
			case 0:
				Ext.Msg.show({
					title: '提示',
					msg: '连接超时或与服务器断开连接,请联系管理员!',
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
				break;
			default:
				Ext.Msg.show({
					title: '提示',
					msg: '错误代码:' + response.status + ',请联系管理员!',
					buttons: Ext.Msg.OK,
					icon: Ext.Msg.ERROR
				});
		}
	},
	
	storeLoadFailure: function() {
		
	},
	
	error: function(message) {
		Ext.Msg.show({
			title: '提示',
			msg: message,
			buttons: Ext.Msg.OK,
			icon: Ext.Msg.ERROR
		});
	}
}, function() {
	Emp.MessageBox = Emp.msg = Emp.ux.window.MessageBox;
});